REM Basic syntax is as follows: REM REM is the form of a comment for a .bat file REM echo prints a message to the console REM @echo off echo Checking for administrative privileges... REM exit if we don't have admin privileges because we would be unable to open ports, REM create .bat file, etc. >nul 2>&1 net session if %errorlevel% neq 0 ( echo This script requires administrative privileges. echo Please run the script as an administrator. pause exit /b 1 ) else ( echo Administrative privileges detected. ) REM Here we will check if the ports are already open. If they are, REM we know that the file has been run before. Running it twice REM would reinstall on top of WAMP, breaking the Installation set "port80Open=false" set "port443Open=false" REM Check if port 80 is open netstat -an | find "LISTENING" | find ":80" > nul if %errorlevel% equ 0 ( set "port80Open=true" ) REM Check if port 443 is open netstat -an | find "LISTENING" | find ":443" > nul if %errorlevel% equ 0 ( set "port443Open=true" ) REM Display results if %port80Open%==true ( echo Port 80 is already open. Exiting... exit /b 1 ) if %port443Open%==true ( echo Port 443 is already open. Exiting... exit /b 1 ) echo Installing Visual C++ Redistributables... REM 2008 SP1 echo Installing vcredist_2008_sp1_atl_x64... "%~dp0vcredist_2008_sp1_atl_x64.exe" /q echo. echo Installing vcredist_2008_sp1_atl_x86... "%~dp0vcredist_2008_sp1_atl_x86.exe" /q echo. echo Installing vcredist_2008_sp1_mfc_x64... "%~dp0vcredist_2008_sp1_mfc_x64.exe" /q echo. echo Installing vcredist_2008_sp1_mfc_x86... "%~dp0vcredist_2008_sp1_mfc_x86.exe" /q echo. echo Installing vcredist_2008_sp1_x64... "%~dp0vcredist_2008_sp1_x64.exe" /q echo. echo Installing vcredist_2008_sp1_x86... "%~dp0vcredist_2008_sp1_x86.exe" /q echo. REM 2010 SP1 echo Installing vcredist_2010_sp1_x64... "%~dp0vcredist_2010_sp1_x64.exe" /passive /norestart echo. echo Installing vcredist_2010_sp1_x86... "%~dp0vcredist_2010_sp1_x86.exe" /passive /norestart echo. REM 2012 Update 4 echo Installing vcredist_2012_upd4_x64... "%~dp0vcredist_2012_upd4_x64.exe" /passive /norestart echo. echo Installing vcredist_2012_upd4_x86... "%~dp0vcredist_2012_upd4_x86.exe" /passive /norestart echo. REM 2013 Update 5 echo Installing vcredist_2013_upd5_x64... "%~dp0vcredist_2013_upd5_x64.exe" /passive /norestart echo. echo Installing vcredist_2013_upd5_x86... "%~dp0vcredist_2013_upd5_x86.exe" /passive /norestart echo. REM 2022 echo Installing vcredist_2022_x64... "%~dp0vcredist_2022_x64.exe" /passive /norestart echo. echo Installing vcredist_2022_x86... "%~dp0vcredist_2022_x86.exe" /passive /norestart echo. echo Now installing WAMP server. Please be patient! This step takes a while. "%~dp0wampserver3.3.2_x64.exe" /VERYSILENT /NORESTART echo. REM commented out port scanner because it may require user intervention, and it REM blocks the view of the console REM echo Installing Port Scanner... REM "%~dp0Advanced_Port_Scanner_2.5.3869.exe" /VERYSILENT /NORESTART REM echo. echo Enabling and starting WampServer services... :: Enable Wamp Apache service sc config wampapache64 start=auto echo Enabling Wamp Apache service... :: Start Wamp Apache service net start wampapache64 echo Starting Wamp Apache service... :: Enable Wamp MySQL service sc config wampmysqld64 start=auto echo Enabling Wamp MySQL service... :: Start Wamp MySQL service net start wampmysqld64 echo Starting Wamp MySQL service... :: Enable wampmariadb64 service sc config wampmariadb64 start=auto echo Enabling Wamp MySQL service... :: Start wampmariadb64 service net start wampmariadb64 echo Starting Wamp MySQL service... echo WampServer services are now set to start automatically. echo Installation complete. :: Generate and execute another batch file to start WampServer Manager set "generatedBatchFile=RunWampServer.bat" ( echo @echo off echo start "" "C:\wamp64\wampmanager.exe" ) > "%generatedBatchFile%" echo Batch file '%generatedBatchFile%' has been created. :: Copy the generated batch file to the startup folder set "startupFolder=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup" copy "%generatedBatchFile%" "%startupFolder%" echo Batch file '%generatedBatchFile%' has been copied to the startup folder. REM rather than disable the firewall, we can be more secure and REM only open the ports that we need echo Opening ports for WampServer... :: Open port 80 for Apache (HTTP) netsh advfirewall firewall add rule name="OpenPort80" dir=in action=allow protocol=TCP localport=80 :: Open port 443 for Apache (HTTPS) netsh advfirewall firewall add rule name="OpenPort443" dir=in action=allow protocol=TCP localport=443 :: Open port 3306 for MySQL netsh advfirewall firewall add rule name="OpenPort3306" dir=in action=allow protocol=TCP localport=3306 echo Ports for WampServer have been opened. REM we now need to shutdown the system for changes to take effect shutdown /r /t 0